<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Amitav Roy
 * Date: 6/9/13
 * Time: 9:52 AM
 * To change this template use File | Settings | File Templates.
 */

class Expense_m extends CI_Model {
  public function __construct() {
    parent::__construct();
    $this->entity_type = 'expense';
    $this->expense_tbl = 'expense e';
    $this->desc_tbl = 'description d';
    $this->limit = 15;
  }

  public function get_expense($offsetRecords = 0) {
    $this->db->select()
      ->from($this->expense_tbl)
      ->join($this->desc_tbl, 'd.eid=e.eid')
      ->where('d.entity_type', $this->entity_type)
      ->order_by('e.date', 'desc')
      ->limit($this->limit,$offsetRecords);

    $query = $this->db->get();

    if ($query->num_rows() > 0) {
      return $query->result_array();
    }
    else {
      return false;
    }
  }

  public function get_expense_by_id() {

  }
}